import React, { FC, useEffect, useState } from 'react'
import Recommend from '@/compents/Recommend'
import Category from '@/compents/Category'
import { Affix } from 'antd'
import style from '../compent.module.scss'
import { getAllBack } from '@/api/article'
const Index: FC = () => {
  const [backList, setbackList] = useState([])
  console.log(backList)

  useEffect(() => {
    getAllBack()
      .then(({ data }) => {
        console.log(data.data[0])

        setbackList(data.data[0])
      })
      .catch((err) => {
        console.log(err)
      })
  }, [])
  return (
    <div className={style.con}>
      <div className={style.left}>
        {
          // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
          backList && backList.length > 0
            ? backList.map((item: any, index: number) => {
              return (
                  <div key={index}>
                    <b>{item.title}</b>

                    <img src={item.cover} alt="" width={200} />

                    <p>{item.summary}</p>
                  </div>
              )
            })
            : '暂无数据'
        }
      </div>
      <div className={style.right}>
        <Affix offsetTop={20}>
          <Recommend />
          <Category />
        </Affix>
      </div>
    </div>
  )
}

export default Index
